app_family.controller("controller_datacalendar", function($scope, $rootScope, httpRequest, $location) {
	$rootScope.$broadcast('currentModule', 'controller_datacalendar');
	$rootScope.$broadcast('footerFlag', false); // 是否显示底部导航
	$scope.imagebasepath = imagebasepath;
	data_sessionStorage = JSON.parse(sessionStorage.getItem('data_sessionStorage'));
	
	/**
	 * 判断是否用手机登录过
	 */
	if (sessionStorage.getItem('data_sessionStorage')) {
		var familyPhone = data_sessionStorage.familyInfo.phone;
		if (familyPhone == '' || familyPhone == null) {
			window.location.replace(basepath + 'login.html');
			return;
		}
	} else {
		window.location.replace(basepath + 'login.html');
		return;
	}
	
	$scope.older_account = data_sessionStorage.data_searchFamilyInfo.older_account; // 账号
	/**
	 * 根据账号，查询个人信息
	 */ 
	httpRequest.getOlderInfo({
		account : $scope.older_account
	}, function (data) {
		if (data.success === true) {
			$scope.olderInfoObj = data.obj;
		} else if (data.success === false) {
			$.dialog.showToast({msgTxt : data.msg});
		}
	});
	
	/**
	 * 根据账号、日期，获取生活日历
	 */
	$scope.getLiveDayByOlder = function (account, date) {
		httpRequest.getLiveDayByOlder({
			account : account,
			date : date
		}, function (data) {
			if (data.success === true) {
				$scope.dataLiveDayList = data.obj;
			} else if (data.success === false) {
				$.dialog.showToast({msgTxt : data.msg});
			}
		});
	};
	
	/**
	 * 页面初始化 查询当天的订单
	 */
	$scope.older_account = data_sessionStorage.data_searchFamilyInfo.older_account; // 账号
	var d = new Date();
	$scope.date = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
	$scope.getLiveDayByOlder($scope.older_account, $scope.date);
	
	/**
	 * 检索日期控件
	 */
	$('#dateSearch').mobiscroll().calendar({
        theme: 'mobiscroll',  
        lang: 'zh', 
        display: 'bottom',   
        controls: ['date'],
        dateFormat : 'yy-mm-dd',
        maxDate : new Date(),
        layout : 'fixed',
        setText: '确定',
        cancelText: '取消',
        onBeforeShow: function (inst) {
        	
        },
        onSelect: function (valueText, inst) {
        	var older_account = data_sessionStorage.data_searchFamilyInfo.older_account; // 账号
        	$scope.getLiveDayByOlder(older_account, valueText);
        },
        onCancel : function (valueText, inst) {
        	
        }
	});
});